import model from "./Model";
module.exports = class testModel extends require("./Model") {
    static addTest(req, res) {
        return new Promise((resolve, reject) => {
            let info = req.body;
            let sql = 'insert into emp set ?'
            this.query(sql, info).then(result => {
                resolve({status:200,message:"success",other:result});
            }).catch(error => {
                reject({status:400,message:"error",other:error});
            })
        })
    }
    static deleteTest(req, res) {
        return new Promise((resolve, reject) => {
            let id = req.body;
            let sql = 'DELETE FROM emp WHERE id = ?'
            this.query(sql, [id]).then(result => {
                resolve({status:200,message:"success",other:result});
            }).catch(error => {
                reject({status:400,message:"error",other:error});
            })
        })
    }
    static changeTest(req, res) {
        return new Promise((resolve, reject) => {
            let {name,newName} = req.body;
            let sql = 'insert into emp set ?'
            this.query(sql, {name,newName}).then(result => {
                resolve({status:200,message:"success",other:result});
            }).catch(error => {
                reject({status:400,message:"error",other:error});
            })
        })
    }
    
}